package com.campus_assistant.common;

import lombok.Data;

@Data
public class ToVue {
    private int code;
    private String msg;
    private Long total;
    private Object data;
    public static ToVue fail(){//后端未查到数据
        return toVue(400,"失败",0L,null);
    }
    public static ToVue suc(){//以下方法是成功查到数据
        return toVue(200,"成功",0L,null);
    }
    public static ToVue suc(Object data){
        return toVue(200,"成功",0L,data);
    }
    public static ToVue suc(Long total,Object data){
        return toVue(200,"成功",total,data);
    }
    private static ToVue toVue(int code,String msg,Long total,Object data){
        ToVue toVue=new ToVue();
        toVue.setCode(code);
        toVue.setMsg(msg);
        toVue.setTotal(total);
        toVue.setData(data);
        return toVue;
    }
}
